#include "context.h"
#include <string.h>
#include <stdio.h>

/*
 * Ajoute le contexte c au contexte courant
 */
void push(struct context *cur, char *c){
	char tmp[100];
	strcpy(cur->cont[cur->position],c);
	(cur->position)++;
	sprintf(tmp,"%s.",c);
	strcat(cur->scont,tmp);
}

/*
 * Retire le dernier contexte rencontré
 */
void pop(struct context *cur){
	int i = 0;
	char tmp[100];
	(cur->position)--;
	for(i = 0; i < cur->position; i++){
		sprintf(tmp,"%s.",cur->cont[i]);
		strcat(cur->scont,tmp);
	}
}

/*
 * Initialise la structure avec un contexte vide (globale)
 */
void init_cont(struct context *cur){
	int i = 0;
	cur->position = 0;
	for(i = 0; i < 100; i++){
		strcpy(cur->cont[i],"");
	}
	strcpy(cur->scont,"");
}